package com.recSys.model;

import java.util.Calendar;
import java.util.Date;

public class User {
    private Integer id;

    private String portrait;

    private String trueName;

    private Integer gender;

    private String IDCard;

    private String email;

    private String mobile;

    private String password;

    private Date loginTime;

    private Integer role;

    // 0为通过微信openId注册，1为通过PC端注册
    private Integer type;

    // 微信用户唯一标识
    private String openId;

    private Integer status;
    private String validateCode;
    private Date registerTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (id != null ? !id.equals(user.id) : user.id != null) return false;
        if (portrait != null ? !portrait.equals(user.portrait) : user.portrait != null) return false;
        if (trueName != null ? !trueName.equals(user.trueName) : user.trueName != null) return false;
        if (gender != null ? !gender.equals(user.gender) : user.gender != null) return false;
        if (IDCard != null ? !IDCard.equals(user.IDCard) : user.IDCard != null) return false;
        if (email != null ? !email.equals(user.email) : user.email != null) return false;
        if (mobile != null ? !mobile.equals(user.mobile) : user.mobile != null) return false;
        if (password != null ? !password.equals(user.password) : user.password != null) return false;
        if (loginTime != null ? !loginTime.equals(user.loginTime) : user.loginTime != null) return false;
        if (role != null ? !role.equals(user.role) : user.role != null) return false;
        if (type != null ? !type.equals(user.type) : user.type != null) return false;
        if (openId != null ? !openId.equals(user.openId) : user.openId != null) return false;
        if (status != null ? !status.equals(user.status) : user.status != null) return false;
        if (validateCode != null ? !validateCode.equals(user.validateCode) : user.validateCode != null) return false;
        return registerTime != null ? registerTime.equals(user.registerTime) : user.registerTime == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (portrait != null ? portrait.hashCode() : 0);
        result = 31 * result + (trueName != null ? trueName.hashCode() : 0);
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        result = 31 * result + (IDCard != null ? IDCard.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (mobile != null ? mobile.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (loginTime != null ? loginTime.hashCode() : 0);
        result = 31 * result + (role != null ? role.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (openId != null ? openId.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (validateCode != null ? validateCode.hashCode() : 0);
        result = 31 * result + (registerTime != null ? registerTime.hashCode() : 0);
        return result;
    }

    /**
     * 获取激活码过期时间，默认2天
     *
     * @return
     */
    public Date getLastActivateTime() {
        Calendar cl = Calendar.getInstance();
        cl.setTime(registerTime);
        cl.add(Calendar.DATE, 2);

        return cl.getTime();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getValidateCode() {
        return validateCode;
    }

    public void setValidateCode(String validateCode) {
        this.validateCode = validateCode;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait == null ? null : portrait.trim();
    }

    public String getTrueName() {
        return trueName;
    }

    public void setTrueName(String trueName) {
        this.trueName = trueName == null ? null : trueName.trim();
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getIDCard() {
        return IDCard;
    }

    public void setIDCard(String IDCard) {
        this.IDCard = IDCard == null ? null : IDCard.trim();
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile == null ? null : mobile.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }

    public Integer getRole() {
        return role;
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

}